<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style>
.ancestors *{ 
	display: block;
	border: 2px solid lightgrey;
	color: lightgrey;
	padding: 5px;
	margin: 15px;
}
</style>
		<!--[if lt IE 9]>
    <script src="jquery-1.9.0.js"></script>
<![endif]-->
		<!--[if gte IE 9]><!-->
		<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
		<!--<![endif]-->
		<script type="text/javascript">
$(document).ready(function(){
	$("span").parent().css({"color":"red","border":"2px solid red"});
});
		</script>
	</head>

<body class="ancestors">body (曾曾祖父节点)
	<div style="width:500px;">div (曾祖父节点)
		<ul>ul (祖父节点)  
			<li>li (直接父节点)
				<span>span</span>
			</li>
		</ul>   
	</div>
	</body>
</html>